﻿using Autofac;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using CCLog;
using ScienceAIApp.ViewModels;
using ScienceAppService.ModuleInterface;

namespace ScienceAIApp;
public class AppIoc
{
    public static IContainer AppContainer { get; set; }

    public static void Register()
    {
        var builder = new ContainerBuilder();

        builder.RegisterType<LoggerService>().As<ILoggerService>();

        var serviceAsm = typeof(IImageShowService).Assembly;
        builder.RegisterAssemblyTypes(serviceAsm).Where(t => t.Name.EndsWith("Service")).AsImplementedInterfaces().SingleInstance();

        var appAsm = typeof(App).Assembly;
        builder.RegisterAssemblyTypes(appAsm).Where(t => t.Name.EndsWith("ViewModel")).AsSelf();


        //builder.RegisterAssemblyTypes(appAsm).Where(t => t.Name.EndsWith("ViewModel")).AsSelf().SingleInstance();
        //builder.RegisterType<ImageMarkDrawViewModel>().AsSelf();

        builder.RegisterType<MainWindow>().AsSelf().SingleInstance();

        builder.RegisterType<AlertWin>().AsSelf().SingleInstance();

        AppContainer = builder.Build();
    }
}
